import socket

client=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(('192.168.3.39', 6666))
file_name=input('input file name:')
client.send(file_name.encode('utf-8'))
try:
    with open('downloadasdfasdf.py', 'wb') as file:
        while True:
            file_data=client.recv(1024)
            if file_data:
                file.write(file_data)
                print(file_data)
            else:
                break
except Exception as e:
    print('error downloading: ', e)
else:
    print(file_name, 'download success')
client.close()